package com.mty.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mty.common.entity.AclUser;
import com.mty.common.vo.Result;
import com.mty.security.annotation.RequiresPermission;
import com.mty.system.service.AclUserService;
import com.mty.system.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：Teacher马（2508531326@qq.com）
 * @date ：Created in 2022/12/2 11:39
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/system/user")
public class AclUserController {
    @Autowired
    private AclUserService userService;

    @GetMapping("/getByName/{username}")
    public Result<AclUser> getName(@PathVariable String username){
        return userService.findByName(username);
    }

    @GetMapping("list")
    @RequiresPermission(value="user:list")
    public String list(){
        System.out.println("~~~~~~~~~~用户查询~~~~~~~~~~~~~");
        return "用户查询";
    }
    @GetMapping("info")
    public Result<AclUser> info(){

        return userService.findUserinfo();
    }

    @PostMapping("getUserByPage/{current}/{pageSize}")
    public Result<IPage<AclUser>> getUserByPage(@PathVariable(required = true) Integer current, @PathVariable(required =true ) Integer pageSize,
                                                @RequestBody UserVo userVo
    ){
        return userService.findByConditionPage(current,pageSize,userVo);
    }
}
